package org.dreamfly.dreamalarm.task;

import java.util.List;

import org.dreamfly.dreamalarm.bean.Alarm;
import org.dreamfly.dreamalarm.inter.ListComponent;
import org.dreamfly.dreamalarm.util.db.DataBaseHelper;

import android.content.Context;

import com.github.droidfu.concurrent.BetterAsyncTask;

public class ListAsyncTask extends
                 BetterAsyncTask<String, Void, String> {

	ListComponent component;
	List<Alarm> list;
	
	public ListAsyncTask(Context arg0, ListComponent component,Boolean needDialog) {
		super(arg0);
		// TODO Auto-generated constructor stub
		this.component = component;
		if (!needDialog) {
			super.disableDialog();
		}
	}

	@Override
	protected String doCheckedInBackground(Context context, String... obj)
			throws Exception {
		super.doCheckedInBackground(context, obj);
		
		DataBaseHelper db=DataBaseHelper.getInstance();
		list=db.listFullSecect();
		
		return "";
	}
	
	@Override
	protected void after(Context arg0, String arg1) {
		// TODO Auto-generated method stub
		component.listSuccessRefresh(list);
	}

	@Override
	protected void handleError(Context arg0, Exception arg1) {
		// TODO Auto-generated method stub
		component.listErrorRefresh();
	}

}
